package com.xyht.sca_s.student_manage_system.modules.purchaseRequisition.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xyht.sca_s.student_manage_system.modules.purchaseRequisition.entity.SmsPurchaseRequisitionProcess;
import com.xyht.sca_s.student_manage_system.modules.purchaseRequisition.mapper.SmsPurchaseRequisitionProcessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RequisitionInit {

    @Autowired
    private SmsPurchaseRequisitionProcessMapper smsPurchaseRequisitionProcessMapper;

    String[] departmentNameArray = {"部门负责人","后勤处","分管院长", "院长"};

    @Bean
    public void Init() {
        List<SmsPurchaseRequisitionProcess> processList =
                smsPurchaseRequisitionProcessMapper.selectList(new QueryWrapper<>());
        if (processList == null || processList.size() < 1) {
            int sort = 1;
            for (String departmentName : departmentNameArray) {
                SmsPurchaseRequisitionProcess addProcess =
                        new SmsPurchaseRequisitionProcess();
                addProcess.setProcessName(departmentName);
                addProcess.setProcessIsUse(true);
                addProcess.setProcessIsStamp(false);
                addProcess.setProcessIsSign(true);
                addProcess.setProcessIsApplicantEdit(false);
                addProcess.setProcessSort(sort++);
                smsPurchaseRequisitionProcessMapper.insert(addProcess);
            }


        }
    }
}
